package com.guigu.gson;

import org.junit.Test;

import com.google.gson.Gson;

public class GSONTest {
	@Test
	public void test() {
		Gson gson = new Gson();
		Person person = new Person();
		person.setName("zhangsan");
		person.setAge(20);
		String json = gson.toJson(person);
		System.out.println(json);// {"name":"zhangsan","age":20}
		String jsonString = "{\"name\":\"zhangsan\",\"age\":20}";
		Person fromJson = gson.fromJson(json, Person.class);
		System.out.println(fromJson);// Person[name=zhangsan,age=20]
	}
}